﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using IPC.Communication;
using IPC.Communication.Framework.BasicFramework;
using IPC.Communication.Framework.Core;
using IPC.Communication.Framework.Core.Net;
using IPC.Communication.Framework.Reflection;
using IPC.Communication.Framework.Core.Types;

namespace IPC.Communication.Framework.Core.Net
{
    public class NetworkDeviceBase : NetworkDoubleBase, IReadWriteDevice, IReadWriteNet
    {
        private ushort _wordLength = 1;

        protected ushort WordLength
        {
            get { return _wordLength; }
            set { _wordLength = value; }
        }


        public override string ToString()
        {
            return String.Format("NetworkDeviceBase<{0}, {1}>[{2}:{3}]", GetNewNetMessage().GetType(), base.ByteTransform.GetType(), IpAddress, Port);
        }

        [HslMqttApi("ReadByteArray", "")]
        public virtual OperateResult<byte[]> Read(string address, ushort length)
        {
            return new OperateResult<byte[]>(StringResources.Language.NotSupportedFunction);
        }

        [HslMqttApi("WriteByteArray", "")]
        public virtual OperateResult Write(string address, byte[] value)
        {
            return new OperateResult(StringResources.Language.NotSupportedFunction);
        }

        [HslMqttApi("ReadBoolArray", "")]
        public virtual OperateResult<bool[]> ReadBool(string address, ushort length)
        {
            return new OperateResult<bool[]>(StringResources.Language.NotSupportedFunction);
        }

        [HslMqttApi("ReadBool", "")]
        public virtual OperateResult<bool> ReadBool(string address)
        {
            return ByteTransformHelper.GetResultFromArray(ReadBool(address, 1));
        }

        [HslMqttApi("BatchRead", "批量读取")]
        public OperateResult<Dictionary<string, object>> BatchRead(Dictionary<string, DataTypeEnum> addresses, int batchNumber)
        {
            return new OperateResult<Dictionary<string, object>>(StringResources.Language.NotSupportedFunction);
        }

        [HslMqttApi("BatchWrite", "批量写入")]
        public OperateResult BatchWrite(Dictionary<string, object> addresses, int batchNumber)
        {
            return new OperateResult(StringResources.Language.NotSupportedFunction);
        }

        [HslMqttApi("WriteBoolArray", "")]
        public virtual OperateResult Write(string address, bool[] value)
        {
            return new OperateResult(StringResources.Language.NotSupportedFunction);
        }

        [HslMqttApi("WriteBool", "")]
        public virtual OperateResult Write(string address, bool value)
        {
            return Write(address, new bool[1]
		{
			value
		});
        }

        public OperateResult<T> ReadCustomer<T>(string address) where T : IDataTransfer, new()
        {
            OperateResult<T> operateResult = new OperateResult<T>();
            T content = new T();
            OperateResult<byte[]> operateResult2 = Read(address, content.ReadCount);
            if (operateResult2.IsSuccess)
            {
                content.ParseSource(operateResult2.Content);
                operateResult.Content = content;
                operateResult.IsSuccess = true;
            }
            else
            {
                operateResult.ErrorCode = operateResult2.ErrorCode;
                operateResult.Message = operateResult2.Message;
            }
            return operateResult;
        }

        public OperateResult WriteCustomer<T>(string address, T data) where T : IDataTransfer, new()
        {
            return Write(address, data.ToSource());
        }

        public virtual OperateResult<T> Read<T>() where T : class, new()
        {
            return HslReflectionHelper.Read<T>(this);
        }

        public virtual OperateResult Write<T>(T data) where T : class, new()
        {
            return HslReflectionHelper.Write(data, this);
        }

        [HslMqttApi("ReadInt16", "")]
        public OperateResult<short> ReadInt16(string address)
        {
            return ByteTransformHelper.GetResultFromArray(ReadInt16(address, 1));
        }

        [HslMqttApi("ReadInt16Array", "")]
        public virtual OperateResult<short[]> ReadInt16(string address, ushort length)
        {
            return ByteTransformHelper.GetResultFromBytes(Read(address, (ushort)(length * WordLength)), (byte[] m) => base.ByteTransform.TransInt16(m, 0, length));
        }

        [HslMqttApi("ReadUInt16", "")]
        public OperateResult<ushort> ReadUInt16(string address)
        {
            return ByteTransformHelper.GetResultFromArray(ReadUInt16(address, 1));
        }

        [HslMqttApi("ReadUInt16Array", "")]
        public virtual OperateResult<ushort[]> ReadUInt16(string address, ushort length)
        {
            return ByteTransformHelper.GetResultFromBytes(Read(address, (ushort)(length * WordLength)), (byte[] m) => base.ByteTransform.TransUInt16(m, 0, length));
        }

        [HslMqttApi("ReadInt32", "")]
        public OperateResult<int> ReadInt32(string address)
        {
            return ByteTransformHelper.GetResultFromArray(ReadInt32(address, 1));
        }

        [HslMqttApi("ReadInt32Array", "")]
        public virtual OperateResult<int[]> ReadInt32(string address, ushort length)
        {
            return ByteTransformHelper.GetResultFromBytes(Read(address, (ushort)(length * WordLength * 2)), (byte[] m) => base.ByteTransform.TransInt32(m, 0, length));
        }

        [HslMqttApi("ReadUInt32", "")]
        public OperateResult<uint> ReadUInt32(string address)
        {
            return ByteTransformHelper.GetResultFromArray(ReadUInt32(address, 1));
        }

        [HslMqttApi("ReadUInt32Array", "")]
        public virtual OperateResult<uint[]> ReadUInt32(string address, ushort length)
        {
            return ByteTransformHelper.GetResultFromBytes(Read(address, (ushort)(length * WordLength * 2)), (byte[] m) => base.ByteTransform.TransUInt32(m, 0, length));
        }

        [HslMqttApi("ReadFloat", "")]
        public OperateResult<float> ReadFloat(string address)
        {
            return ByteTransformHelper.GetResultFromArray(ReadFloat(address, 1));
        }

        [HslMqttApi("ReadFloatArray", "")]
        public virtual OperateResult<float[]> ReadFloat(string address, ushort length)
        {
            return ByteTransformHelper.GetResultFromBytes(Read(address, (ushort)(length * WordLength * 2)), (byte[] m) => base.ByteTransform.TransSingle(m, 0, length));
        }

        [HslMqttApi("ReadInt64", "")]
        public OperateResult<long> ReadInt64(string address)
        {
            return ByteTransformHelper.GetResultFromArray(ReadInt64(address, 1));
        }

        [HslMqttApi("ReadInt64Array", "")]
        public virtual OperateResult<long[]> ReadInt64(string address, ushort length)
        {
            return ByteTransformHelper.GetResultFromBytes(Read(address, (ushort)(length * WordLength * 4)), (byte[] m) => base.ByteTransform.TransInt64(m, 0, length));
        }

        [HslMqttApi("ReadUInt64", "")]
        public OperateResult<ulong> ReadUInt64(string address)
        {
            return ByteTransformHelper.GetResultFromArray(ReadUInt64(address, 1));
        }

        [HslMqttApi("ReadUInt64Array", "")]
        public virtual OperateResult<ulong[]> ReadUInt64(string address, ushort length)
        {
            return ByteTransformHelper.GetResultFromBytes(Read(address, (ushort)(length * WordLength * 4)), (byte[] m) => base.ByteTransform.TransUInt64(m, 0, length));
        }

        [HslMqttApi("ReadDouble", "")]
        public OperateResult<double> ReadDouble(string address)
        {
            return ByteTransformHelper.GetResultFromArray(ReadDouble(address, 1));
        }

        [HslMqttApi("ReadDoubleArray", "")]
        public virtual OperateResult<double[]> ReadDouble(string address, ushort length)
        {
            return ByteTransformHelper.GetResultFromBytes(Read(address, (ushort)(length * WordLength * 4)), (byte[] m) => base.ByteTransform.TransDouble(m, 0, length));
        }

        [HslMqttApi("ReadString", "")]
        public virtual OperateResult<string> ReadString(string address, ushort length)
        {
            return ReadString(address, length, Encoding.ASCII);
        }

        public virtual OperateResult<string> ReadString(string address, ushort length, Encoding encoding)
        {
            return ByteTransformHelper.GetResultFromBytes(Read(address, length), (byte[] m) => base.ByteTransform.TransString(m, 0, m.Length, encoding));
        }

        [HslMqttApi("WriteInt16Array", "")]
        public virtual OperateResult Write(string address, short[] values)
        {
            return Write(address, base.ByteTransform.TransByte(values));
        }

        [HslMqttApi("WriteInt16", "")]
        public virtual OperateResult Write(string address, short value)
        {
            return Write(address, new short[1]
		{
			value
		});
        }

        [HslMqttApi("WriteUInt16Array", "")]
        public virtual OperateResult Write(string address, ushort[] values)
        {
            return Write(address, base.ByteTransform.TransByte(values));
        }

        [HslMqttApi("WriteUInt16", "")]
        public virtual OperateResult Write(string address, ushort value)
        {
            return Write(address, new ushort[1]
		{
			value
		});
        }

        [HslMqttApi("WriteInt32Array", "")]
        public virtual OperateResult Write(string address, int[] values)
        {
            return Write(address, base.ByteTransform.TransByte(values));
        }

        [HslMqttApi("WriteInt32", "")]
        public OperateResult Write(string address, int value)
        {
            return Write(address, new int[1]
		{
			value
		});
        }

        [HslMqttApi("WriteUInt32Array", "")]
        public virtual OperateResult Write(string address, uint[] values)
        {
            return Write(address, base.ByteTransform.TransByte(values));
        }

        [HslMqttApi("WriteUInt32", "")]
        public OperateResult Write(string address, uint value)
        {
            return Write(address, new uint[1]
		{
			value
		});
        }

        [HslMqttApi("WriteFloatArray", "")]
        public virtual OperateResult Write(string address, float[] values)
        {
            return Write(address, base.ByteTransform.TransByte(values));
        }

        [HslMqttApi("WriteFloat", "")]
        public OperateResult Write(string address, float value)
        {
            return Write(address, new float[1]
		{
			value
		});
        }

        [HslMqttApi("WriteInt64Array", "")]
        public virtual OperateResult Write(string address, long[] values)
        {
            return Write(address, base.ByteTransform.TransByte(values));
        }

        [HslMqttApi("WriteInt64", "")]
        public OperateResult Write(string address, long value)
        {
            return Write(address, new long[1]
		{
			value
		});
        }

        [HslMqttApi("WriteUInt64Array", "")]
        public virtual OperateResult Write(string address, ulong[] values)
        {
            return Write(address, base.ByteTransform.TransByte(values));
        }

        [HslMqttApi("WriteUInt64", "")]
        public OperateResult Write(string address, ulong value)
        {
            return Write(address, new ulong[1]
		{
			value
		});
        }

        [HslMqttApi("WriteDoubleArray", "")]
        public virtual OperateResult Write(string address, double[] values)
        {
            return Write(address, base.ByteTransform.TransByte(values));
        }

        [HslMqttApi("WriteDouble", "")]
        public OperateResult Write(string address, double value)
        {
            return Write(address, new double[1]
		{
			value
		});
        }

        [HslMqttApi("WriteString", "")]
        public virtual OperateResult Write(string address, string value)
        {
            return Write(address, value, Encoding.ASCII);
        }

        public virtual OperateResult Write(string address, string value, int length)
        {
            return Write(address, value, length, Encoding.ASCII);
        }

        public virtual OperateResult Write(string address, string value, Encoding encoding)
        {
            byte[] array = base.ByteTransform.TransByte(value, encoding);
            if (WordLength == 1)
            {
                array = SoftBasic.ArrayExpandToLengthEven(array);
            }
            return Write(address, array);
        }

        public virtual OperateResult Write(string address, string value, int length, Encoding encoding)
        {
            byte[] data = base.ByteTransform.TransByte(value, encoding);
            if (WordLength == 1)
            {
                data = SoftBasic.ArrayExpandToLengthEven(data);
            }
            data = SoftBasic.ArrayExpandToLength(data, length);
            return Write(address, data);
        }

        [HslMqttApi("WaitBool", "")]
        public OperateResult<TimeSpan> Wait(string address, bool waitValue, int readInterval = 100, int waitTimeout = -1)
        {
            return ReadWriteNetHelper.Wait(this, address, waitValue, readInterval, waitTimeout);
        }

        [HslMqttApi("WaitInt16", "")]
        public OperateResult<TimeSpan> Wait(string address, short waitValue, int readInterval = 100, int waitTimeout = -1)
        {
            return ReadWriteNetHelper.Wait(this, address, waitValue, readInterval, waitTimeout);
        }

        [HslMqttApi("WaitUInt16", "")]
        public OperateResult<TimeSpan> Wait(string address, ushort waitValue, int readInterval = 100, int waitTimeout = -1)
        {
            return ReadWriteNetHelper.Wait(this, address, waitValue, readInterval, waitTimeout);
        }

        [HslMqttApi("WaitInt32", "")]
        public OperateResult<TimeSpan> Wait(string address, int waitValue, int readInterval = 100, int waitTimeout = -1)
        {
            return ReadWriteNetHelper.Wait(this, address, waitValue, readInterval, waitTimeout);
        }

        [HslMqttApi("WaitUInt32", "")]
        public OperateResult<TimeSpan> Wait(string address, uint waitValue, int readInterval = 100, int waitTimeout = -1)
        {
            return ReadWriteNetHelper.Wait(this, address, waitValue, readInterval, waitTimeout);
        }

        [HslMqttApi("WaitInt64", "")]
        public OperateResult<TimeSpan> Wait(string address, long waitValue, int readInterval = 100, int waitTimeout = -1)
        {
            return ReadWriteNetHelper.Wait(this, address, waitValue, readInterval, waitTimeout);
        }

        [HslMqttApi("WaitUInt64", "")]
        public OperateResult<TimeSpan> Wait(string address, ulong waitValue, int readInterval = 100, int waitTimeout = -1)
        {
            return ReadWriteNetHelper.Wait(this, address, waitValue, readInterval, waitTimeout);
        }

        //[AsyncStateMachine(typeof(<WaitAsync>d__60))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<TimeSpan>> WaitAsync(string address, bool waitValue, int readInterval = 100, int waitTimeout = -1)
        //{
        //    <WaitAsync>d__60 stateMachine = new <WaitAsync>d__60();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<TimeSpan>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.waitValue = waitValue;
        //    stateMachine.readInterval = readInterval;
        //    stateMachine.waitTimeout = waitTimeout;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WaitAsync>d__61))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<TimeSpan>> WaitAsync(string address, short waitValue, int readInterval = 100, int waitTimeout = -1)
        //{
        //    <WaitAsync>d__61 stateMachine = new <WaitAsync>d__61();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<TimeSpan>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.waitValue = waitValue;
        //    stateMachine.readInterval = readInterval;
        //    stateMachine.waitTimeout = waitTimeout;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WaitAsync>d__62))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<TimeSpan>> WaitAsync(string address, ushort waitValue, int readInterval = 100, int waitTimeout = -1)
        //{
        //    <WaitAsync>d__62 stateMachine = new <WaitAsync>d__62();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<TimeSpan>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.waitValue = waitValue;
        //    stateMachine.readInterval = readInterval;
        //    stateMachine.waitTimeout = waitTimeout;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WaitAsync>d__63))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<TimeSpan>> WaitAsync(string address, int waitValue, int readInterval = 100, int waitTimeout = -1)
        //{
        //    <WaitAsync>d__63 stateMachine = new <WaitAsync>d__63();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<TimeSpan>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.waitValue = waitValue;
        //    stateMachine.readInterval = readInterval;
        //    stateMachine.waitTimeout = waitTimeout;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WaitAsync>d__64))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<TimeSpan>> WaitAsync(string address, uint waitValue, int readInterval = 100, int waitTimeout = -1)
        //{
        //    <WaitAsync>d__64 stateMachine = new <WaitAsync>d__64();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<TimeSpan>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.waitValue = waitValue;
        //    stateMachine.readInterval = readInterval;
        //    stateMachine.waitTimeout = waitTimeout;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WaitAsync>d__65))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<TimeSpan>> WaitAsync(string address, long waitValue, int readInterval = 100, int waitTimeout = -1)
        //{
        //    <WaitAsync>d__65 stateMachine = new <WaitAsync>d__65();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<TimeSpan>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.waitValue = waitValue;
        //    stateMachine.readInterval = readInterval;
        //    stateMachine.waitTimeout = waitTimeout;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WaitAsync>d__66))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<TimeSpan>> WaitAsync(string address, ulong waitValue, int readInterval = 100, int waitTimeout = -1)
        //{
        //    <WaitAsync>d__66 stateMachine = new <WaitAsync>d__66();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<TimeSpan>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.waitValue = waitValue;
        //    stateMachine.readInterval = readInterval;
        //    stateMachine.waitTimeout = waitTimeout;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadAsync>d__67))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult<byte[]>> ReadAsync(string address, ushort length)
        //{
        //    <ReadAsync>d__67 stateMachine = new <ReadAsync>d__67();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<byte[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.length = length;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__68))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, byte[] value)
        //{
        //    <WriteAsync>d__68 stateMachine = new <WriteAsync>d__68();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadBoolAsync>d__69))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult<bool[]>> ReadBoolAsync(string address, ushort length)
        //{
        //    <ReadBoolAsync>d__69 stateMachine = new <ReadBoolAsync>d__69();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<bool[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.length = length;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadBoolAsync>d__70))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult<bool>> ReadBoolAsync(string address)
        //{
        //    <ReadBoolAsync>d__70 stateMachine = new <ReadBoolAsync>d__70();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<bool>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__71))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, bool[] value)
        //{
        //    <WriteAsync>d__71 stateMachine = new <WriteAsync>d__71();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__72))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, bool value)
        //{
        //    <WriteAsync>d__72 stateMachine = new <WriteAsync>d__72();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadCustomerAsync>d__73<>))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<T>> ReadCustomerAsync<T>(string address) where T : IDataTransfer, new()
        //{
        //    <ReadCustomerAsync>d__73<T> stateMachine = new <ReadCustomerAsync>d__73<T>();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<T>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteCustomerAsync>d__74<>))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> WriteCustomerAsync<T>(string address, T data) where T : IDataTransfer, new()
        //{
        //    <WriteCustomerAsync>d__74<T> stateMachine = new <WriteCustomerAsync>d__74<T>();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.data = data;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadAsync>d__75<>))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult<T>> ReadAsync<T>() where T : class, new()
        //{
        //    <ReadAsync>d__75<T> stateMachine = new <ReadAsync>d__75<T>();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<T>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__76<>))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync<T>(T data) where T : class, new()
        //{
        //    <WriteAsync>d__76<T> stateMachine = new <WriteAsync>d__76<T>();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.data = data;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadInt16Async>d__77))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<short>> ReadInt16Async(string address)
        //{
        //    <ReadInt16Async>d__77 stateMachine = new <ReadInt16Async>d__77();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<short>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadInt16Async>d__78))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult<short[]>> ReadInt16Async(string address, ushort length)
        //{
        //    <ReadInt16Async>d__78 stateMachine = new <ReadInt16Async>d__78();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<short[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.length = length;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadUInt16Async>d__79))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<ushort>> ReadUInt16Async(string address)
        //{
        //    <ReadUInt16Async>d__79 stateMachine = new <ReadUInt16Async>d__79();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<ushort>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadUInt16Async>d__80))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult<ushort[]>> ReadUInt16Async(string address, ushort length)
        //{
        //    <ReadUInt16Async>d__80 stateMachine = new <ReadUInt16Async>d__80();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<ushort[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.length = length;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadInt32Async>d__81))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ReadInt32Async(string address)
        //{
        //    <ReadInt32Async>d__81 stateMachine = new <ReadInt32Async>d__81();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadInt32Async>d__82))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult<int[]>> ReadInt32Async(string address, ushort length)
        //{
        //    <ReadInt32Async>d__82 stateMachine = new <ReadInt32Async>d__82();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.length = length;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadUInt32Async>d__83))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<uint>> ReadUInt32Async(string address)
        //{
        //    <ReadUInt32Async>d__83 stateMachine = new <ReadUInt32Async>d__83();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<uint>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadUInt32Async>d__84))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult<uint[]>> ReadUInt32Async(string address, ushort length)
        //{
        //    <ReadUInt32Async>d__84 stateMachine = new <ReadUInt32Async>d__84();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<uint[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.length = length;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadFloatAsync>d__85))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<float>> ReadFloatAsync(string address)
        //{
        //    <ReadFloatAsync>d__85 stateMachine = new <ReadFloatAsync>d__85();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<float>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadFloatAsync>d__86))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult<float[]>> ReadFloatAsync(string address, ushort length)
        //{
        //    <ReadFloatAsync>d__86 stateMachine = new <ReadFloatAsync>d__86();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<float[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.length = length;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadInt64Async>d__87))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<long>> ReadInt64Async(string address)
        //{
        //    <ReadInt64Async>d__87 stateMachine = new <ReadInt64Async>d__87();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<long>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadInt64Async>d__88))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult<long[]>> ReadInt64Async(string address, ushort length)
        //{
        //    <ReadInt64Async>d__88 stateMachine = new <ReadInt64Async>d__88();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<long[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.length = length;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadUInt64Async>d__89))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<ulong>> ReadUInt64Async(string address)
        //{
        //    <ReadUInt64Async>d__89 stateMachine = new <ReadUInt64Async>d__89();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<ulong>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadUInt64Async>d__90))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult<ulong[]>> ReadUInt64Async(string address, ushort length)
        //{
        //    <ReadUInt64Async>d__90 stateMachine = new <ReadUInt64Async>d__90();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<ulong[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.length = length;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadDoubleAsync>d__91))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<double>> ReadDoubleAsync(string address)
        //{
        //    <ReadDoubleAsync>d__91 stateMachine = new <ReadDoubleAsync>d__91();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<double>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadDoubleAsync>d__92))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult<double[]>> ReadDoubleAsync(string address, ushort length)
        //{
        //    <ReadDoubleAsync>d__92 stateMachine = new <ReadDoubleAsync>d__92();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<double[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.length = length;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadStringAsync>d__93))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult<string>> ReadStringAsync(string address, ushort length)
        //{
        //    <ReadStringAsync>d__93 stateMachine = new <ReadStringAsync>d__93();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.length = length;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadStringAsync>d__94))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult<string>> ReadStringAsync(string address, ushort length, Encoding encoding)
        //{
        //    <ReadStringAsync>d__94 stateMachine = new <ReadStringAsync>d__94();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.length = length;
        //    stateMachine.encoding = encoding;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__95))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, short[] values)
        //{
        //    <WriteAsync>d__95 stateMachine = new <WriteAsync>d__95();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.values = values;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__96))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, short value)
        //{
        //    <WriteAsync>d__96 stateMachine = new <WriteAsync>d__96();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__97))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, ushort[] values)
        //{
        //    <WriteAsync>d__97 stateMachine = new <WriteAsync>d__97();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.values = values;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__98))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, ushort value)
        //{
        //    <WriteAsync>d__98 stateMachine = new <WriteAsync>d__98();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__99))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, int[] values)
        //{
        //    <WriteAsync>d__99 stateMachine = new <WriteAsync>d__99();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.values = values;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__100))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> WriteAsync(string address, int value)
        //{
        //    <WriteAsync>d__100 stateMachine = new <WriteAsync>d__100();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__101))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, uint[] values)
        //{
        //    <WriteAsync>d__101 stateMachine = new <WriteAsync>d__101();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.values = values;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__102))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> WriteAsync(string address, uint value)
        //{
        //    <WriteAsync>d__102 stateMachine = new <WriteAsync>d__102();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__103))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, float[] values)
        //{
        //    <WriteAsync>d__103 stateMachine = new <WriteAsync>d__103();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.values = values;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__104))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> WriteAsync(string address, float value)
        //{
        //    <WriteAsync>d__104 stateMachine = new <WriteAsync>d__104();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__105))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, long[] values)
        //{
        //    <WriteAsync>d__105 stateMachine = new <WriteAsync>d__105();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.values = values;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__106))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> WriteAsync(string address, long value)
        //{
        //    <WriteAsync>d__106 stateMachine = new <WriteAsync>d__106();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__107))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, ulong[] values)
        //{
        //    <WriteAsync>d__107 stateMachine = new <WriteAsync>d__107();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.values = values;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__108))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> WriteAsync(string address, ulong value)
        //{
        //    <WriteAsync>d__108 stateMachine = new <WriteAsync>d__108();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__109))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, double[] values)
        //{
        //    <WriteAsync>d__109 stateMachine = new <WriteAsync>d__109();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.values = values;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__110))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> WriteAsync(string address, double value)
        //{
        //    <WriteAsync>d__110 stateMachine = new <WriteAsync>d__110();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__111))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, string value)
        //{
        //    <WriteAsync>d__111 stateMachine = new <WriteAsync>d__111();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__112))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, string value, Encoding encoding)
        //{
        //    <WriteAsync>d__112 stateMachine = new <WriteAsync>d__112();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.encoding = encoding;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__113))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, string value, int length)
        //{
        //    <WriteAsync>d__113 stateMachine = new <WriteAsync>d__113();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.length = length;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__114))]
        //[DebuggerStepThrough]
        //public virtual Task<OperateResult> WriteAsync(string address, string value, int length, Encoding encoding)
        //{
        //    <WriteAsync>d__114 stateMachine = new <WriteAsync>d__114();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.address = address;
        //    stateMachine.value = value;
        //    stateMachine.length = length;
        //    stateMachine.encoding = encoding;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}
    }
}
